import unittest

from selenium import webdriver
from selenium.webdriver.firefox.service import Service


class MyTestCaseFireFox(unittest.TestCase):
    driver = None

    @classmethod
    def setUpClass(cls) -> None:
        # 注册 驱动打开的位置
        service = Service(executable_path="../../../dirver_exe/geckodriver.exe")
        # 打开浏览器  driver 代表 浏览器对象
        cls.driver = webdriver.Firefox(service=service)

    def test_baidu(self):
        self.driver.get("https://www.baidu.com")

    def tearDownClass(cls) -> None:
        cls.driver.close()  # 只会关闭一个标签页
        # cls.driver.quit()  # 直接退出浏览器 并且关闭所有的标签页


if __name__ == '__main__':
    unittest.main()
